package com.opengate.base.page;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 曳戈泰尔
 * @version 1.0
 * @description 页数据返回实体
 * @date 2023/4/26 5:46 PM
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "页数据返回实体")
public class PageData<T> {

    @Schema(description = "页码", example = "1", required = true)
    private Integer pageNum = 1;

    @Schema(description = "页大小", example = "20", required = true)
    private Integer pageSize = 20;

    @Schema(description = "记录数", required = true)
    private int totalCount;

    @Schema(description = "数据记录", required = true)
    private List<T> dataList = new ArrayList<>();

    public PageData(Integer pageIndex, Integer pageSize) {
        this.pageNum = pageIndex;
        this.pageSize = pageSize;
    }

    public PageData(Integer pageIndex, Integer pageSize, int totalCount) {
        this.pageNum = pageIndex;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
    }

    public PageData(Integer pageIndex, Integer pageSize, List<T> dataList) {
        this.pageNum = pageIndex;
        this.pageSize = pageSize;
        this.dataList = dataList;
    }
}
